<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Webpack 构建流程图</title>
  <style>
    body {
      font-family: 'Segoe UI', sans-serif;
      background: #f9f9f9;
      padding: 2rem;
      color: #333;
    }
    .stage {
      border-left: 4px solid #42b983;
      padding: 1rem 1.5rem;
      margin: 1rem 0;
      background: #fff;
      box-shadow: 0 2px 4px rgba(0,0,0,0.05);
      border-radius: 6px;
    }
    .stage h3 {
      margin: 0 0 0.5rem;
      font-size: 1.25rem;
    }
    .stage p {
      margin: 0.25rem 0;
    }
    .arrow {
      text-align: center;
      font-size: 1.5rem;
      color: #bbb;
    }
  </style>
</head>
<body>
  <h1>Webpack 构建流程图</h1>

  <div class="stage">
    <h3>1. 初始化配置</h3>
    <p>读取 webpack.config.js 并合并默认配置。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>2. 创建 Compiler 实例</h3>
    <p>创建 Compiler 对象并初始化插件。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>3. 启动构建 (compiler.run)</h3>
    <p>Webpack 开始正式执行构建流程。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>4. 创建 Compilation 实例</h3>
    <p>开始编译所有模块并跟踪依赖。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>5. 构建模块 Module</h3>
    <p>解析模块、调用 Loader 转换代码。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>6. 完成模块依赖图</h3>
    <p>构建出完整的依赖图 ModuleGraph。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>7. 生成 Chunk</h3>
    <p>根据入口点生成代码块，应用优化策略。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>8. 生成 Asset</h3>
    <p>将 Chunk 转换为最终的输出文件（bundle.js / .css 等）。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>9. 触发 emit 钩子</h3>
    <p>插件可在这里修改资源或生成额外文件。</p>
  </div>
  <div class="arrow">⬇️</div>

  <div class="stage">
    <h3>10. 写入文件系统</h3>
    <p>所有构建产物输出到 dist 目录中。</p>
  </div>

</body>
</html>
